package algorithm;

import static org.junit.Assert.*;
import static org.junit.Assert.fail;

import java.io.IOException;

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import cards.Card;

/**
 * 
 */

/**
 * @author tbittma1
 * 
 */
public class HiLoTest {

	private Card testCard;
	private HiLoAlgorithm testAlgorithm;

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		testAlgorithm = new HiLoAlgorithm();
	}

	/**
	 * Test method for
	 * {@link algorithm.HiLoAlgorithm#updateRunningCount(algorithm.card)}.
	 * 
	 * @throws IOException
	 */
	@Test
	public void testUpdateRunningCountCard() throws IOException {
		testCard = new Card(10, "", 0, null);
		testAlgorithm.updateRunningCount(testCard);
		assertEquals(-1, testAlgorithm.getRunningCount());
		testAlgorithm = new HiLoAlgorithm();
		testCard = new Card(2, "", 0, null);
		testAlgorithm.updateRunningCount(testCard);
		assertEquals(1, testAlgorithm.getRunningCount());
	}

	/**
	 * Test method for {@link algorithm.CountingAlgorithm#updateTrueCount(int)}.
	 * 
	 * @throws IOException
	 */
	@Test
	public void testUpdateTrueCount() throws IOException {
		testCard = new Card(10, "", 0, null);
		testAlgorithm.updateRunningCount(testCard);
		testAlgorithm.updateRunningCount(testCard);
		testAlgorithm.updateRunningCount(testCard);
		testAlgorithm.updateRunningCount(testCard);
		testAlgorithm.updateTrueCount(2);
		assertEquals(-2, (int) testAlgorithm.getTrueCount());
		testAlgorithm = new HiLoAlgorithm();
		testCard = new Card(2, "", 0, null);
		testAlgorithm.updateRunningCount(testCard);
		testAlgorithm.updateRunningCount(testCard);
		testAlgorithm.updateRunningCount(testCard);
		testAlgorithm.updateRunningCount(testCard);
		testAlgorithm.updateTrueCount(2);
		assertEquals(2, (int) testAlgorithm.getTrueCount());

	}

}
